"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var index_1 = require("@/index");
function default_1(chartTarget, dataSource, reRender, destroyMySelf) {
    var container = document.getElementById(chartTarget === null || chartTarget === void 0 ? void 0 : chartTarget.getConfig("container"));
    var innerSpan = document.createElement("span");
    var innerButton = document.createElement("button");
    if (container) {
        container.innerHTML = "";
        container.append(innerSpan);
        container.append(innerButton);
    }
    innerButton.innerText = "点击我进行下钻";
    innerButton.addEventListener("click", function () {
        var events = chartTarget === null || chartTarget === void 0 ? void 0 : chartTarget.getConfig("events");
        if (events["button1"].type == "setFilter") {
            /**
             * 该属性由图表组件自动生成，当用户点击触发当前图标的时候，图标的返回数据就是这个属性
             */
            var params = {
                id: 10,
                name: "南京"
            };
            var newChart = index_1.ChartIdMap.get(events["button1"].target);
            newChart === null || newChart === void 0 ? void 0 : newChart.self.setDataSourceFilter(params);
        }
        else if (events["button1"].type == "redirect") {
            console.log(destroyMySelf);
            destroyMySelf && destroyMySelf();
            var newChart = index_1.ChartIdMap.get(events["button1"].target);
            newChart === null || newChart === void 0 ? void 0 : newChart.self.render();
        }
        console.log(chartTarget === null || chartTarget === void 0 ? void 0 : chartTarget.getConfig());
    }, false);
    (0, index_1.effect)(function () {
        innerSpan.innerHTML = (chartTarget === null || chartTarget === void 0 ? void 0 : chartTarget.getConfig("title")) || "空空如也";
    }, [chartTarget]);
    (0, index_1.effect)(function () {
        console.log("dataSource，指定重绘区域工作，" + (chartTarget === null || chartTarget === void 0 ? void 0 : chartTarget.getConfig("id")));
        console.log(dataSource === null || dataSource === void 0 ? void 0 : dataSource.getFilter());
        innerSpan.innerHTML = (chartTarget === null || chartTarget === void 0 ? void 0 : chartTarget.getConfig("title")) || "空空如也";
    }, [dataSource]);
}
exports.default = default_1;
